<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/30
 * Time: 9:26
 */

namespace app\admin\controller;


use think\Controller;
use think\Db;

class Digui extends Controller
{
    public function select(){
        $row = Db::table('tangjie')->select();
        $this->date($row);
    }
    //无限极分类
    public function date($row,$fid=0,$str=''){
        $str.=($fid==0)?'':'&nbsp;&nbsp;&nbsp;&nbsp;';
        foreach ($row as $v){
            if ($v['f_id']==$fid){
                echo $str.$v['type'].'<br>';
                $this->date($row,$v['id'],$str);
            }
        }
    }
//    云背篓
    public function get_can(){
    //    1.a标签 传参数    get  获取 方式
    //    2.form 表单传参    get   post 获取方式
    //    3.ajax  传参      get   post 获取方式
    //    4. curl 传参      get   post 获取方式
    //    ....
//        $id = '服装';
//        $info = Db::table('tangjie')->where('type = "'.$id.'"')->select();
//        var_dump($info);exit();
//        <a href="{:url('Digui/put_can',array('id'=>$id))}">跳转1</a>
        $id = request()->route('id');
        $where = '';
        $where .= !empty($id)?'id = '.$id:'';
        if(!empty($_POST)){
            $where .= !empty($_POST['f_id'])?'f_id ='.$_POST['f_id']:'';
            if(!empty($_POST['f_id'])){
                $where .= !empty($_POST['s_id'])?' and s_id ='.$_POST['s_id']:'';
            }else{
                $where .= !empty($_POST['s_id'])?'s_id ='.$_POST['s_id']:'';
            }
        }

        $data = model('Mmm')->index($where);

//        var_dump($data);
        return $this->fetch('index/get_can');
    }
    public function put_can(){
        $data = request()->param('gaohan');
        $argv = array(
            0 => 'tangjie',
            1 => 'gaohan'
        );

        $aaa = 'asdadsa';
        $ahh = 'asasasa"'.$aaa.'"sdasdsad';
        $id = 1;





        echo json_encode($argv);exit();   //把 数组转成json

//        接收路由的参数
//        $id = request()->route('id');
//        所有的参数
//        $id = request()->param('id');

    }
}